package com.jyy.prefabricated.service.impl;

import com.jyy.prefabricated.entity.ScoringComments;
import com.jyy.prefabricated.mapper.ScoringCommentsMapper;
import com.jyy.prefabricated.service.ScoringCommentsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 分数点评表(ScoringComments)表服务实现类
 *
 * @author mrl
 * @since 2021-07-20 14:49:43
 */
@Service("scoringCommentsService")
public class ScoringCommentsServiceImpl implements ScoringCommentsService {
    @Resource
    private ScoringCommentsMapper scoringCommentsMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ScoringComments queryById(Integer id) {
        return this.scoringCommentsMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ScoringComments> queryAllByLimit(int offset, int limit) {
        return this.scoringCommentsMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param scoringComments 实例对象
     * @return 实例对象
     */
    @Override
    public ScoringComments insert(ScoringComments scoringComments) {
        this.scoringCommentsMapper.insert(scoringComments);
        return scoringComments;
    }

    /**
     * 修改数据
     *
     * @param scoringComments 实例对象
     * @return 实例对象
     */
    @Override
    public ScoringComments update(ScoringComments scoringComments) {
        this.scoringCommentsMapper.update(scoringComments);
        return this.queryById(scoringComments.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.scoringCommentsMapper.deleteById(id) > 0;
    }
}